home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / nt_dsp1.lzh / NT_DSP1.MSA / LFLTS / LATGEN.HLP < prev    next >
Text File  |  1989-01-24  |  6KB  |  134 lines

  1.          Name: LATGEN.ASM
  2.          Type: Assembler Macro
  3.       Version: 1.0
  4.   Last Change:  8-Aug-86
  5.  
  6.   Description: Lattice FIR Filter Assembler Macro
  7.  
  8.  A general form of the lattice  filter  is  show  in  Figure  6.
  9.  
  10.  
  11.  
  12.                     
  13.    A   >---->(+)------------>(+)----------->(+)---------->---|
  14.    (in)       ^      /        ^      /       ^      /        |
  15.                \    k3         \    k2        \    k1        |
  16.                 \  /            \  /           \  /          |
  17.                   /               /              /           V
  18.                  / \             / \            / \          |
  19.                 /   \           /   \          /   \         |
  20.                /   -k3         /   -k2        /   -k1        |
  21.               v     |         v     |        v     |         |
  22.         -----(+)<------1/z---(+)<-----1/z---(+)<-------1/z---|
  23.         |                  |              |                |
  24.         v3                 v2             v1               v0
  25.         |                   \____     ____/                |
  26.          \                       \   /                    /
  27.            -----------------------(+)--------------------
  28.                                    |________ A (out)
  29.  
  30.                               Figure 6
  31.  
  32.  The k and v coefficients can be obtained from  a  direct  form
  33.  filter.
  34.  
  35.  For the filter shown, the pointers R0 and R4  are  initialized
  36.  to point as shown:
  37.  
  38.        r0                         r4
  39.        |                          |
  40.        v                          v
  41.     x: k3 k2 k1 v3 v2 v1 v0    y: s4 s3 s2 s1
  42.  
  43.        m0=6 (=2*order, mod 7)     m4=3 (=order, mod 4)
  44.  
  45.  The register R0  is  initialized  to  point  to  the  first  k
  46.  coefficient  (k3)  and  the pointer R4 initially points to the
  47.  first location allocated for the state variables.  The  modulo
  48.  register  m0  is set to two times the number of k coefficients
  49.  (6 in this example) and the register m4 is set to  the  number
  50.  of coefficients (3 in this example).
  51.  
  52.  The input sample is put in register A and the filter macro  is
  53.  then called as:
  54.  
  55.         latgen     order         ;call filter
  56.  
  57.  where 'order' is the number of k coefficients in the lattice.
  58.  
  59.  FILTER OPERATION
  60.  
  61.  The operation of this filter is similar to  the  operation  of
  62.  the  all  pole filter described previously (latiir) and can be
  63.  described (refer to Figure 6 and the macro 'latgen'):
  64.  
  65.  1.  The input sample is assumed to be in register A.
  66.  
  67.  2.  The first MOVE loads the  first  k  coefficient  (k3)  and
  68.      increments   the  pointer  R0  to  point  to  the  next  k
  69.      coefficient.  Similarly, the state variable is loaded  and
  70.      the  pointer  R4  is  decremented to point to the previous
  71.      state variable.  The previous state variable  is  actually
  72.      the value that v3 was multiplied by on the previous sample
  73.      time.  This value is not needed and can be overwritten.
  74.  
  75.  3.  The DO loop now will perform ORDER passes to calculate the
  76.      new state variables.
  77.  
  78.  4.  The first MACR will calculate the top value by subtracting
  79.      from  the  value  in A the product of k (X0) and the state
  80.      (Y0).  The previous state calculated (B) is now saved  and
  81.      the pointer R4 is incremented to point back to the current
  82.      state value.  Note that the B register  initially  has  an
  83.      unknown  value  so  the  first  pass  of the loop saves an
  84.      unknown value.
  85.  
  86.  5.  The top A value is then moved to a product  register  (X1)
  87.      so  that  it  can  later be multiplied.  The B register is
  88.      loaded with  the  current  state  variable  and  then  the
  89.      pointer  to  the  state  variables  (R4) is incremented to
  90.      point to the next state variable.
  91.  
  92.  6.  The new state is calculated by adding to the current state
  93.      variable  (B)  the product of the top value (X1) and the k
  94.      coefficient (X0).
  95.  
  96.  7.  The loop is now complete  and  has  calculated  and  saved
  97.      ORDER-1  of  the  state  variables.   (ORDER+1  values are
  98.      needed to calculate the v coefficient taps).
  99.  8.  The output is then rounded, the second last state is saved
  100.      and  the  pointer  R4  is incremented to point to the next
  101.      unused state variable.  Note that at this point that R4 is
  102.      pointing  to  the  unknown value that was first written in
  103.      the loop.
  104.  
  105.  9.  The value in A is saved as  the  state  variable  and  the
  106.      pointer  R4  is  incremented  to  point  to the next state
  107.      variable.  At this  point,  R4  points  to  the  state  to
  108.      multiply  V3.   The  A  register  is also cleared to later
  109.      accumulate the FIR taps.
  110.  
  111. 10.  The state pointed to by R4 is  then  loaded  into  product
  112.      register Y0.
  113.  
  114. 11.  The FIR taps are calculated by using a REP instruction  to
  115.      calculate  ORDER  number of taps.  Note that the first tap
  116.      coefficient V3 was loaded by the last instruction  of  the
  117.      DO loop.
  118.  
  119. 12.  The FIR taps are then calculated.  All except for the last
  120.      tap are calculated.
  121.  
  122. 13.  The last tap  is  then  calculated  and  rounded  and  the
  123.      pointer  R4  is  incremented  to  point  to the next state
  124.      variable.   This  state  variable  was  the  second  state
  125.      variable calculated by the loop.  The first state variable
  126.      calculated is only needed to multiply v3 and is not needed
  127.      at the next sample time.
  128.  
  129.  Benchmarks  for  this  filter  are:   12  instructions,   4N+9
  130.  instruction cycles.
  131.  
  132.  The test program 'latgent.asm' in the DSPLIB gives an example
  133.  of how to call this filter.
  134.